

<div class="section" id="sitemaplist">
  <div class="section-title">Quản lý khách hàng</div>
  <div class="section-content padding1">
    <form name="frm" id="frm" action="<?php echo $action?>" method="post" enctype="multipart/form-data">
    
      <div class="button right">
        <a class="button save" onclick="save()">Lưu</a>
		<a class="button cancel" href="?route=deliman/khachhang">Bỏ qua</a>   
        <input type="hidden" name="khachhangid" value="<?php echo $item['khachhangid']?>">
        
        <input type="hidden" name="masokhachhang" value="<?php echo $item['masokhachhang'] ?>" />
      </div>
      <div class="clearer">^&nbsp;</div>
      <div id="error" class="error" style="display:none"></div>
      <div>
        <p>
          <label>Họ tên khách hàng:</label>
          <br />
          <input type="text" name="hoten" value="<?php echo $item['hoten']?>" class="text" size=60 />
        </p>
        <fieldset style="border:1px solid #cfcfcf;padding-left:10px;width:350px">
          <legend style="font-family:Tahoma, Geneva, sans-serif; font-size:12px">Khu vực:</legend>
          <p>
           
            <select id="khuvucid" name="khuvucid">
            	<?php foreach($khuvucs as $khuvuc){ ?>
                <option value="<?php echo $khuvuc['khuvucid']?>"><?php echo $this->string->getPrefix("&nbsp; &nbsp; &nbsp; &nbsp;",$khuvuc['level']);?><?php echo $khuvuc['tenkhuvuc']?></option>
                <?php }?>
            </select>
          </p>
          
        </fieldset>
        <p>
          <label>Địa chỉ:</label>
          <br />
          <input type="text" name="diachi" value="<?php echo $item['diachi']?>" class="text" size=60 />
        </p>
        <p>
          <label>Email:</label>
          <br />
          <input type="text" name="email" value="<?php echo $item['email']?>" class="text" size=60 />
        </p>
        <p>
          <label>Điện thoại:</label>
          <br />
          <input type="text" name="dienthoai" value="<?php echo $item['dienthoai']?>" class="text" size=60 />
        </p>
        <p>
          <label>Ghi chú:</label>
          <br />
           <textarea  cols="57" rows="8" name="ghichu" id="ghichu<?php echo $item['id']?>"><?php echo $item['ghichu'] ?></textarea>
        </p>
      </div>
    </form>
  </div>
</div>
<script language="javascript">

$(document).ready(function(){
	/*$("#makhuvuc_tinhthanh").change(function(){
		$('#makhuvuc_quanhuyen').load('?route=deliman/khachhang/getkhuvuc&loai=quanhuyen&id='+$(this).val()+"&select=<?php echo $khuvuc['quanhuyenid']?>", function(){
			$('#makhuvuc_phuongxa').load('?route=deliman/khachhang/getkhuvuc&loai=phuongxa&id='+$('#makhuvuc_quanhuyen').val()+"&select=<?php echo $khuvuc['phuongxaid']?>", function(){
				$('#khuvucid').load('?route=deliman/khachhang/getkhuvuc&loai=duong&id='+$('#makhuvuc_phuongxa').val()+"&select=<?php echo $khuvuc['khuvucid']?>", function(){});
				
			});	
		});
		
		
		
	});
	$("#makhuvuc_tinhthanh").change();
	$("#makhuvuc_quanhuyen").change(function(){
		
		$('#makhuvuc_phuongxa').load('?route=deliman/khachhang/getkhuvuc&loai=phuongxa&id='+$(this).val(), function(){
			$('#khuvucid').load('?route=deliman/khachhang/getkhuvuc&loai=duong&id='+$(this).val(), function(){});		
		});
		
		
	});
	
	$("#makhuvuc_phuongxa").live('change',function(){
		$('#khuvucid').load('?route=deliman/khachhang/getkhuvuc&loai=duong&id='+$(this).val(), function(){});
	});*/
	$('#khuvucid').val("<?php echo $item['khuvucid']?>");
	

});


<!--thực hiện chức năng save dữ liệu-->
function save()
{
	$.blockUI({ message: "<h1>Please wait...</h1>" }); 
		//var str=$('#sonha').val()+ " " + $('#khuvucid option:selected').text() + ", " + $('#makhuvuc_phuongxa option:selected').text() + ", " + $('#makhuvuc_quanhuyen option:selected').text() + ", " + $('#makhuvuc_tinhthanh option:selected').text();
	//$('#diachi').val(str);
	$.post("?route=deliman/khachhang/save", $("#frm").serialize(),
		function(data){
			if(data == "true")
			{
				window.location = "?route=deliman/khachhang";
				
			}
			else
			{
			
				$('#error').html(data).show('slow');
				$.unblockUI();
				
			}
			
		}
	);
}
</script> 
